package utility;

/**
 *
 * @author Sonny Sandberg
 */
public abstract class Converter 
{
    public static int booleanToInt(boolean input)
    {
        int output = 0;
        if (input == true)
        {
            output = 1;
        }
        return output;
    }
    
    public static boolean intToBoolean(int input)
    {
        boolean output = false;
        if (input == 1)
        {
            output = true;
        }
        return output;
    }
    
    public static String booleanToString(boolean input)
    {
        String output = "Nej";
        if (input == true)
        {
            output = "Ja";
        }
        return output;
    }
    
    /**
     * Konverter 00.00.0000 til 0000-00-00
     * @param String 
     * @return String
     */
    public static String dateToMysqlDate(String date)
    {
        String streng = "";
        
        if (date.length() == 10)
        {
            StringBuilder str = new StringBuilder();
            str.append(date.substring(6, 10));
            str.append("-");
            str.append(date.substring(3, 5));
            str.append("-");
            str.append(date.substring(0, 2));
            
            streng = ""+str;
        }
        
        return streng;
    }
}